{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1、构建一个list，名称为 li1 ,包含四个元素，第一个元素为整数，第二个元素为小数，第三个元素为字符串，第四个元素为bool值,并使用type()函数显示出每个元素的类型。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "li1 = [12,123.4,'str1',True]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2、有几个字符串分别是用 'utf-8' ，'gbk' ，'gb2312'，'big5'四中方式进行编码的，请还原出原来的字符串。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T07:26:09.318715Z",
     "start_time": "2020-07-07T07:26:09.297715Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'解艳刚'"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "'史艳丽'"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "'查天星'"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "'台灣島'"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "str1 = b'\\xe8\\xa7\\xa3\\xe8\\x89\\xb3\\xe5\\x88\\x9a'\n",
    "str2 = b'\\xca\\xb7\\xd1\\xde\\xc0\\xf6'\n",
    "str3 = b'\\xb2\\xe9\\xcc\\xec\\xd0\\xc7'\n",
    "str4 = b'\\xa5x\\xc6W\\xaeq'\n",
    "str1.decode('utf-8')\n",
    "str2.decode('gbk')\n",
    "str3.decode('gb2312')\n",
    "str4.decode('big5')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3、构造一个list，li1，里面的元素是从1-100的整数； 通过li1再构造一个li2，里面元素是li1的倒序，从100-1的整数，通过list切片分别取出li1的 前10个数，后10个数 以及 中间10个数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T07:44:34.490521Z",
     "start_time": "2020-07-07T07:44:34.484521Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['shan']"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name1 = list('shan')\n",
    "name = [''.join(name1), ]\n",
    "name"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4、把自己的名字的全拼构造成3个list，例如：我的名字 feng ming shan ，构造成 name1 = ['f', 'e', 'n', 'g'] ， name2 = ['m', 'i', 'n', 'g'] ， name3 = ['s', 'h', 'a', 'n'] \n",
    "\n",
    "再通过连接list的操作，把这3个list变成一个list ： name = ['feng','ming','shan']\n",
    "\n",
    "再通过连接list的操作，把这3个list变成一个字符串： name_str = 'feng ming shan' #注意中间用空格隔开"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T08:03:36.321726Z",
     "start_time": "2020-07-07T08:03:36.314726Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['shiyanli', 'xieyangang', 'zhatianxing']"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "li1 = ['zhatianxing', 'xieyangang' , 'shiyanli']\n",
    "li1.sort()\n",
    "li1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5、已知 list1 = ['zhatianxing', '史艳丽', 'xieyangang'] 。\n",
    "\n",
    "请在第2个和第3个元素之间，插入一个名字 'fengmingshan'；\n",
    "\n",
    "请将 '史艳丽' 修改为拼音 'shiyanli'；\n",
    "\n",
    "请将 list1 按照字母顺序进行排序\n",
    "\n",
    "请用 print()函数 输出这4个人的 名字 和 名字的长度：\n",
    "例：\n",
    "'shiyanli' ： 8\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "list1 = ['zhatianxing', '史艳丽', 'xieyangang']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T08:22:20.421932Z",
     "start_time": "2020-07-07T08:22:20.414932Z"
    }
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-50-8f9643deba70>, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-50-8f9643deba70>\"\u001b[1;36m, line \u001b[1;32m2\u001b[0m\n\u001b[1;33m    总分 =\u001b[0m\n\u001b[1;37m         ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "list2 = ['94', '95', '96' , '98' , '99']\n",
    "平均分 = \n",
    "最高分 = \n",
    "最低分 = "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "6、已知一个考试成绩list， list2 = ['95', '96' , '98' , '99' ,'100'] ，\n",
    "\n",
    "请求出这5个人的 平均分，最高分 和 最低分,必须写出求的函数或过程，直接写答案得0分。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "list2 = ['95', '96' , '98' , '99' ,'100']\n",
    "平均分 = \n",
    "最高分 = \n",
    "最低分 = "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "7、创建一个字典 dict1 包含3个元素 'Name': 'Runoob', 'Age': 7, 'Class': 'two'\n",
    "\n",
    "在dict1中增加一个元素 'town' : 'qujing'\n",
    "\n",
    "用另一种不同的方法在dict1中增加一个元素 'school' : 'middleschool'，不能和上一步相同。\n",
    "\n",
    "更新dict1 'town' 的值为 'xuanwei'\n",
    "\n",
    "用另一种不同的方法，更新dict1 'school'的值为 'highschool'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "8、已知字典 dict2 = {'Name': 'Tom', 'Age': 7, 'Class': 'two', 'School': 'middle', 'Town': 'qujing'},完成下面3个操作。\n",
    "\n",
    "删除 dict2 中的'Town'键\n",
    "\n",
    "清空 dict2 中的元素，保留一个空字典\n",
    "\n",
    "删除整个dict2字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T08:40:17.115936Z",
     "start_time": "2020-07-07T08:40:17.111936Z"
    }
   },
   "outputs": [],
   "source": [
    "dict2 = {'Name': 'Tom', 'Age': 7, 'Class': 'two', 'School': 'middle', 'Town': 'qujing'}\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "9、已知字典 dict3 = {'Name': 'Tom', 'Age': 7, 'Class': 'two', 'School': 'middle', 'Town': 'qujing'},完成下面3个操作。\n",
    "\n",
    "输出dict3所有的键值对 格式为：[('Name', 'Tom'), ('Age', 7)]\n",
    "\n",
    "只输出dict3所有的键 \n",
    "\n",
    "只输出dict3所有的值\n",
    "\n",
    "从 dict3 中查询 'Sex'这个键对应的值，因为该键不存在，所以请返回一个'查不到'字符串,不能直接报错"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T08:47:56.442938Z",
     "start_time": "2020-07-07T08:47:56.417938Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_items([('Name', 'Tom'), ('Age', 7), ('Class', 'two'), ('School', 'middle'), ('Town', 'qujing')])"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "dict_keys(['Name', 'Age', 'Class', 'School', 'Town'])"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "dict_values(['Tom', 7, 'two', 'middle', 'qujing'])"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "'查不到'"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict3 = {'Name': 'Tom', 'Age': 7, 'Class': 'two', 'School': 'middle', 'Town': 'qujing'}\n",
    "dict3.items()\n",
    "dict3.keys()\n",
    "dict3.values()\n",
    "dict3.get('Sex','查不到')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "10、 创建一个集合set1  包含 1到10的整数。\n",
    "\n",
    "创建一个集合set2  包含 11到20的整数。\n",
    "\n",
    "在 set1 中增加3个元素 11，12 ，13\n",
    "\n",
    "在 set1 中删除1个元素 13\n",
    "\n",
    "将 set1 和 set2 合并在一起组成 set3 。\n",
    "\n",
    "判断 13 是否在 set3 里，输出 True 或者 False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T08:55:07.616140Z",
     "start_time": "2020-07-07T08:55:07.609140Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "11、已知两个list，list1 和 list2 \n",
    "\n",
    "求 list1 中不重复的字母有哪几个? \n",
    "\n",
    "求 list1 和 list2 中都有的字母是哪几个? \n",
    "\n",
    "求 list1 中有，但是 list2 中没有的字母是哪几个？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "list1 = ['a', 'e','f','n', 'i', 'i','n','g','a', 'm','m'，'h', 'h','i', 'm', 'n', 's', 'e']\n",
    "list2 =  ['a', 'y','e', 'y','n','a','g','e', 'x', 'i', 'x','e','g','a','n', 'g','x', 'y']\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "12、使用你自己的名字里所有的字母创建一个集合set1， 例如：我的名字 'fengmingshan'  ： {'a', 'e', 'f', 'g', 'h', 'i', 'm', 'n', 's'},必须使用函数，手工创建得0分。\n",
    "\n",
    "求出你的名字里面包含'a' ,'b' , 'c' , 'd' , 'e'这5个字母中的几个，写出用函数求解的过程，直接写答案得0分，"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "13、(20分)小明和小华约好今天下午去做运动，他们先看天气再决定做什么运动，如果天晴，有云，就去打篮球；如果天晴，没有云，就不去打篮球，因为太热了，就改成游泳；如果天阴，不下雨，就去骑单车，如果天阴下雨就去体育馆打羽毛球。请参照下面的例子用if语句写出他们选择运动的原则，并把天气代入语句进行测试看看满不满足题目要求，同一个语句必须同时满足4种天气情况。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T07:09:30.479911Z",
     "start_time": "2020-07-07T07:09:30.470911Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['爬山']\n"
     ]
    }
   ],
   "source": [
    "# 例 \n",
    "天气 = ['晴']\n",
    "运动x = []\n",
    "if '晴' in 天气:\n",
    "    运动x.append('爬山')\n",
    "elif '阴' in 天气:\n",
    "    运动x.append('宅在家')\n",
    "print(运动x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T07:05:27.406510Z",
     "start_time": "2020-07-07T07:05:27.394510Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['打羽毛球']"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "天气1 = ['晴', '有云']\n",
    "天气2 = ['晴', '无云']\n",
    "天气3 = ['阴', '无雨']\n",
    "天气4 = ['阴', '有雨']\n",
    "运动 = []\n",
    "# 请再下面写出 if 条件 语句：\n",
    "if '晴' in 天气4:\n",
    "    if '有云' in 天气4:\n",
    "        运动.append('打篮球')\n",
    "    elif  '无云' in 天气4:\n",
    "        运动.append('游泳')\n",
    "if '阴' in 天气4:\n",
    "    if '无雨' in 天气4:\n",
    "        运动.append('骑单车')\n",
    "    elif '有雨' in 天气4:\n",
    "        运动.append('打羽毛球')\n",
    "运动"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "14、(20分)有一个人，他早点习惯吃油条。如果早点铺有油条他就选油条，最好是搭配豆浆；没有豆浆的话稀豆粉也可以；没有稀豆粉，稀饭也可以；没有稀饭的话，他就不吃油条，因为太干了吃不下；他就改吃米线。如果早点铺没有油条，他就吃米线；如果没有米线，他就吃面条，如果连面条都没有他就不吃早点。\n",
    "\n",
    "早点铺1、2卖的早点不同，用条件语句写出这个人选择早点的原则, 并将早点铺1、2带入条件语句进行测试，看看输出它的最终选择 xuan_ze1 和 xuan_ze2 看看是否符合题目要求。\n",
    "\n",
    "正确的结果应该是：\n",
    "\n",
    "选择1 = ['油条', '豆浆']  \n",
    "\n",
    "选择2 = ['米线'] \n",
    "\n",
    "提示：\n",
    "\n",
    "判断早点铺里有什么早点： \n",
    "\n",
    "if '油条' in 早点铺1:\n",
    "\n",
    "选择早点:  \n",
    "\n",
    "选择1.append('油条')\n",
    "\n",
    "删除选择: \n",
    "\n",
    "选择1.remove('油条')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T06:38:06.764403Z",
     "start_time": "2020-07-07T06:38:06.755403Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['油条', '豆浆']\n"
     ]
    }
   ],
   "source": [
    "# 例:\n",
    "早点铺 = ['油条', '豆浆','米线','面条']\n",
    "选择 = []\n",
    "if '油条' in 早点铺:\n",
    "    选择.append('油条')    \n",
    "    if '豆浆' in 早点铺:    \n",
    "        选择.append('豆浆')            \n",
    "print(选择)      "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-07T06:36:31.148802Z",
     "start_time": "2020-07-07T06:36:31.125802Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['油条', '豆浆']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "['米线']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "早点铺1 = ['油条','豆浆','稀豆粉','稀饭','米线','面条'] \n",
    "早点铺2 = ['油条','包子','馒头','米线','面条'] \n",
    "选择1 = []\n",
    "选择2 = []\n",
    "# 请再下面写出 if 条件 语句\n",
    "if '油条' in 早点铺1:\n",
    "    选择1.append('油条')\n",
    "    if '豆浆' in 早点铺1:\n",
    "        选择1.append('豆浆')\n",
    "    elif '稀豆粉' in 早点铺1:\n",
    "        选择1.append('稀豆粉')\n",
    "    elif '稀饭' in 早点铺1:\n",
    "        选择1.append('稀饭')\n",
    "    else:\n",
    "        选择1.remove('油条')\n",
    "        if  '米线' in 早点铺1:\n",
    "            选择1.append('米线')\n",
    "        elif '面条' in 早点铺1:\n",
    "            选择1.append('面条')\n",
    "elif '米线' in 早点铺1:\n",
    "    选择1.append('米线')\n",
    "elif '面条' in 早点铺1:\n",
    "    选择1.append('面条')    \n",
    "选择1\n",
    "\n",
    "\n",
    "if '油条' in 早点铺2:\n",
    "    选择2.append('油条')\n",
    "    if '豆浆' in 早点铺2:\n",
    "        选择2.append('豆浆')\n",
    "    elif '稀豆粉' in 早点铺2:\n",
    "        选择2.append('稀豆粉')\n",
    "    elif '稀饭' in 早点铺2:\n",
    "        选择2.append('稀饭')\n",
    "    else:\n",
    "        选择2.remove('油条')\n",
    "        if  '米线' in 早点铺2:\n",
    "            选择2.append('米线')\n",
    "        elif '面条' in 早点铺2:\n",
    "            选择2.append('面条')\n",
    "elif '米线' in 早点铺2:\n",
    "    选择2.append('米线')\n",
    "elif '面条' in 早点铺2:\n",
    "    选择2.append('面条')\n",
    "选择2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
